/*
 * @Author: 一路向阳 tt_sunzhenfeng@163.com
 * @Date: 2024-06-02 14:29:09
 * @LastEditors: 一路向阳 tt_sunzhenfeng@163.com
 * @LastEditTime: 2024-06-06 16:19:26
 * @FilePath: \vue3_upload_file\vue3_upload_demo\src\api\upload.js
 * @Description: 上传接口
 */

import request from '@/utils/request';

// 图片上传
export const uploadFile = data => {
  return request.post(`/upload`, data, { 
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  });
}

// 多文件上传
export const uploadMutiFile = data => {
  return request.post(`/muti`, data, { 
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  });
}

// 大文件切片上传
export const uploadCut = (data, onProgress, signal) => {
  return request.post(`/cut`, data, {
    // 文件的上传配置请求头为form-data形式
    headers: {
      'Content-type': 'multipart/form-data;charset=UTF-8',
    },
    onUploadProgress: onProgress,
    signal
  });
}

export const uploadVerify = data => {
  return request.post(`/verify`, data, {
    // 文件的上传配置请求头为form-data形式
    headers: {
      'Content-type': 'multipart/form-data;charset=UTF-8',
    }
  });
}

export const uploadMerge = data => {
  return request.post(`/merge`, data);
}

export const getFilesList = data => {
  const { pageNo, pageSize } = data;
  return request.get(`/files?pageNo=${pageNo}&pageSize=${pageSize}`, data);
}